package com.steven.door.utils;

import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import com.steven.door.App;

import java.io.IOException;

import static butterknife.internal.Utils.arrayOf;

public class SystemUtils {
    //隐藏 虚拟按键
    public static boolean hideNavigation() {
        boolean ishide;
        try {
            String command;
            command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib service call activity 42 s16 com.android.systemui";
            Process proc = Runtime.getRuntime().exec(new String[]{"su", "-c",
                    command});
            proc.waitFor();
            ishide = true;
        } catch (Exception ex) {
            Toast.makeText(App.getMContext(), ex.getMessage(),
                    Toast.LENGTH_LONG).show();
            ishide = false;
        }
        return ishide;
    }
    //显示虚拟键盘
    public static boolean showNavigation(){
        boolean isshow;
        try
        {
            String command;
            command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";
            Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c",
                    command });
            proc.waitFor();
            isshow = true;
        }
        catch (Exception e)
        {
            isshow = false;
            e.printStackTrace();
        }
        return isshow;
    }

    //重启设备
    public static void resetDevice(){
        try {
            Runtime.getRuntime().exec(arrayOf("su","-c","reboot "));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
